<?php
/**
 * Created by PhpStorm.
 * User: wanghongbing
 * Date: 2018/11/16
 * Time: 上午9:12
 */

namespace app\Admin\controller;
use think\Controller;
use app\Admin\model\Admin;
use think\facade\Request;
use think\Model;
use think\Db;

class Profile extends Controller
{
    //个人配置

    public function profile(){
        $title = '个人配置';
        $user = session('user');
        $this ->assign('title',$title);
        $this ->assign('user',$user);
        $profile = Db::name('admin') ->where('username',$user) ->find();
        $this ->assign('profile',$profile);
        return $this ->fetch();
    }
    //存入配置
    public function profilesave(){

       $users = Request::param();
        $user = session('user');
       $password = $this::encryptPassword($users['password']);
        Db::name('admin')
            ->where('username',$user)
            ->update(['username' =>$users['username'],'Email' =>$users['Email'],'name' =>$users['name'],'password' => $password]);
        return $this ->success('修改信息成功','Profile/profile');

    }
   //
    public function encryptPassword($password){

        return sha1(md5($password).'mengyunzhi');

    }

}